package com.eastfair.config.controller.entitycontroller;

import com.eastfair.config.entity.LaunchPicture;
import com.eastfair.config.service.entityservice.LaunchPictureService;
import com.eastfair.core.base.R;
import com.eastfair.projectcore.vo.ConfigAttributeVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 启动闪图（闪屏）控制类
 * <p>
 * Date:2021/8/7
 * Time:15:37
 *
 * @author zjn
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/launchPicture")
@Api(value = "启动闪图（闪屏）控制类", tags = "启动闪图（闪屏）控制类")
public class LaunchPictureController {

    @Autowired
    private LaunchPictureService launchPictureService;

    /**
     * 获取启动闪图（闪屏）属性信息
     *
     * @return
     */
    @GetMapping("/getAttributes")
    @ApiOperation(value = "获取启动闪图（闪屏）属性信息", notes = "获取启动闪图（闪屏）属性信息")
    public R<List<ConfigAttributeVO>> getLaunchPictureAttributes() {
        return R.success(launchPictureService.getAttributes());
    }

    /**
     * 获取启动闪图（闪屏）列表
     *
     * @param launchPicture 启动闪图（闪屏）列表过滤条件
     * @return
     */
    @PostMapping("/getList")
    @ApiOperation(value = "获取启动闪图（闪屏）列表", notes = "获取启动闪图（闪屏）列表")
    public R<List<LaunchPicture>> getList(@RequestBody(required = false) LaunchPicture launchPicture) {
        return R.success(launchPictureService.getList(launchPicture));
    }

    /**
     * 获取启动闪图（闪屏）
     *
     * @param flagId 标识id
     * @return
     */
    @GetMapping("/get/{flagId}")
    @ApiOperation(value = "获取启动闪图（闪屏）", notes = "获取启动闪图（闪屏）")
    public R<LaunchPicture> getLaunchPicture(@PathVariable("flagId") Long flagId) {
        return launchPictureService.get(flagId);
    }

    /**
     * 根据条件获取单个启动闪图（闪屏）（默认查询启用状态）
     * 必填参数：
     * exhibitionId 展会id
     * terminalType 平台类型
     * languageType 语言环境
     *
     * @param launchPicture 启动闪图（闪屏）过滤条件
     * @return 启动闪图（闪屏）实体
     */
    @PostMapping("/getByEntity")
    @ApiOperation(value = "根据条件获取单个启动闪图（闪屏）", notes = "根据条件获取单个启动闪图（闪屏）")
    public R<LaunchPicture> getByEntity(@RequestBody @Validated({LaunchPicture.VerifyGetByEntity.class}) LaunchPicture launchPicture) {
        return launchPictureService.getByEntity(launchPicture);
    }

    /**
     * 新增启动闪图（闪屏）
     *
     * @param launchPicture 启动闪图（闪屏）实体
     * @return 是否成功
     */
    @PostMapping("/saveEntity")
    @ApiOperation(value = "新增启动闪图（闪屏）", notes = "新增启动闪图（闪屏）")
    public R<Boolean> saveEntity(@RequestBody LaunchPicture launchPicture) {
        return launchPictureService.saveEntity(launchPicture);
    }

    /**
     * 删除启动闪图（闪屏）
     *
     * @param flagId 启动闪图（闪屏）标识id
     * @return 是否成功
     */
    @DeleteMapping("/{flagId}")
    @ApiOperation(value = "删除启动闪图（闪屏）", notes = "删除启动闪图（闪屏）")
    public R<Boolean> deleteEntity(@PathVariable("flagId") Long flagId) {
        return launchPictureService.deleteEntity(flagId);
    }

    /**
     * 修改启动闪图（闪屏）信息
     *
     * @param launchPicture 启动闪图（闪屏）信息
     * @return 是否成功
     */
    @PutMapping("/updateEntity")
    @ApiOperation(value = "修改启动闪图（闪屏）信息", notes = "修改启动闪图（闪屏）信息")
    public R<Boolean> updateEntity(@RequestBody LaunchPicture launchPicture) {
        return launchPictureService.updateEntity(launchPicture);
    }

}
